package com.hilinos.base.api.vo;

import java.util.List;

import com.alibaba.fastjson.JSON;
import com.hilinos.base.user.entity.pojo.OrgInfoPoJo;
import com.hilinos.common.util.EntityUtils;

import lombok.Data;
import lombok.SneakyThrows;

@Data
public class OrgInfoVo extends OrgInfoPoJo {

    /**
     * 父机构
     */
    private OrgInfoVo parent;

    /**
     * 下属机构列表
     */
    private List<OrgInfoVo> childs;

    public static OrgInfoVo pojo2Vo(OrgInfoPoJo poJo) {
        return JSON.parseObject(EntityUtils.toJsonString(poJo), OrgInfoVo.class);
    }

    @SneakyThrows
    public static List<OrgInfoVo> pojos2Vos(List<OrgInfoPoJo> poJos) {
        return EntityUtils.entities2Entities(poJos, OrgInfoVo.class);
    }

}
